## Modeling a Max Hold Function

The following example shows you how to emulate a max hold function.

// Reset the analyzer

*RST

:DISPlay:WINDow1:TITLe:DATA 'Max Hold Function Emulation'

// Create a trace with the last extremum as memory trace.

:TRACe:COPY 'LastExtr', 'Trc1'

// Display this last extremum trace.

// Because it's a memory trace it must be displayed in the same diagram as the mother trace.

:DISPlay:WINDow1:TRACe2:FEED 'LastExtr'

:CALCulate1:MATH:SDEFine 'Max (Data, Mem)'

:CALCulate1:MATH:STATe ON

// Single sweep mode

:INITIATE:CONTINUOUS OFF

// Do a single sweep and update trace with the current extremum.

// This is the last extremum for the next sweep

:INITIATE:IMMEDIATE; *WAI

:TRACe:COPY:MATH 'LastExtr', 'Trc1'

// Loop over these 2 commands

:INITIATE:IMMEDIATE; *WAI

:TRACe:COPY:MATH 'LastExtr', 'Trc1'

:INITIATE:IMMEDIATE; *WAI

:TRACe:COPY:MATH 'LastExtr', 'Trc1'

// ..............

// Continous sweep mode

:INITIATE:CONTINUOUS ON

//